package com.hdu.result;


import lombok.Data;

@Data
public class R {

    private static final int SUCCESS = 200;
    private static final int FAIL = 500;


    private int code;
    private String msg;
    private Object data;


    public static R success(Object data) {
        R r = new R();
        r.setCode(SUCCESS);
        r.setData(data);
        return r;
    }

    public static R success() {
        R r = new R();
        r.setCode(SUCCESS);
        r.setMsg("ok");
        return r;
    }

    public static R fail(String msg) {
        R r = new R();
        r.setCode(FAIL);
        r.setMsg(msg);
        return r;
    }


    public boolean isSuccess() {
        return code == SUCCESS;
    }

    public boolean isFail() {
        return code == FAIL;
    }

}
